import type { RouteRecordRaw } from 'vue-router'
import { defineComponent } from 'vue'

export interface RouteMeta {
  // 路由title  一般必填
  title?: string
  // 是否忽略KeepAlive缓存
  ignoreKeepAlive?: boolean
  // 是否固定标签
  affix?: boolean
  // 菜单图标
  icon?: string
  // 当前路由不在菜单显示(包含子路由)
  hideMenu?: boolean
  // 不显示公共标题
  commonTitleHide?: boolean
  // 隐藏根路由
  hideRootMenu?: boolean
}

export type Component<T = any> =
  | ReturnType<typeof defineComponent>
  | (() => Promise<typeof import('*.vue')>)
  | (() => Promise<T>)
// @ts-ignore
export interface AppRouteRecordRaw extends Omit<RouteRecordRaw, 'meta'> {
  name: string
  meta: RouteMeta
  component?: Component | string
  components?: Component
  children?: AppRouteRecordRaw[]
  title?: string
  props?: Recordable
}

export interface MenuState {
  // 展开数组
  openKeys: string[]
  // 当前选中的菜单项 key 数组
  selectedKeys: string[]
  // 收缩状态下展开的数组
  collapsedOpenKeys?: string[]
}

export interface breadcrumbRoute {
  path: string
  breadcrumbName: string
  children?: Array<{
    path: string
    breadcrumbName: string
  }>
}
